Skip to content

fix(session): pin channel open/top-up read-back to receipt block#617

Merged
brendanjryan merged 1 commit into
wevm:mainfrom
grandizzy:georgen/mpp-open-readback-race
Jul 4, 2026
Merged

fix(session): pin channel open/top-up read-back to receipt block#617
brendanjryan merged 1 commit into
wevm:mainfrom
grandizzy:georgen/mpp-open-readback-race

Conversation

@grandizzy

Copy link
Copy Markdown
Contributor

After broadcasting an escrow open/top-up, the server re-reads on-chain channel state at latest and validates it against the receipt. Behind a load-balanced RPC, that read can land on a replica that hasn't yet imported the block the transaction was mined in, returning empty/stale state. Verification then fails with a spurious 402 on-chain channel state does not match open receipt even though the transaction succeeded and the caller was charged.

This pins the read-back to the block from the transaction receipt, so a node either returns authoritative state or errors (and is retried) instead of answering with a lagging view. Transient read failures are retried while the replica catches up.

Tests cover block-pinning (read-back targets the receipt block, not latest) and the retry helper (success, retry-until-success, and exhaustion).

After broadcasting an escrow open/top-up, the server re-reads on-chain
channel state at `latest` and checks it against the receipt. Behind a
load-balanced RPC, that read can land on a replica that has not yet
imported the block the transaction was mined in, returning empty/stale
state. Verification then fails with a spurious 402 "on-chain channel
state does not match open receipt" even though the transaction succeeded
and the caller was charged.

Pin the read-back to the block from the transaction receipt so any node
either returns authoritative state or errors (and is retried) instead of
answering with a lagging view. Also retry transient read failures while
the replica catches up.

Amp-Thread-ID: https://ampcode.com/threads/T-019f2769-0fe3-76ee-a0f0-63b126fd3da0
Co-authored-by: Amp <amp@ampcode.com>
@pkg-pr-new

pkg-pr-new Bot commented Jul 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/mppx@617

commit: 51c5665

@grandizzy grandizzy marked this pull request as ready for review July 3, 2026 12:13

@figtracer figtracer left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

@brendanjryan brendanjryan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find -- thank you!

@brendanjryan brendanjryan merged commit 00d72b0 into wevm:main Jul 4, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants